*****************************************************************************************************************************************************
* PROJECT: 		Exposure to the COVID-19 Stock Market Crash and its Effect on Household Expectations
* DATE: 		Nov 2020
* CONTENT: 		FIGURES
* AUTHORS: 		Tobin Hanspal, Johannes Wohlfart, Anni Weber
*****************************************************************************************************************************************************

		clear all
		set scheme lean2
		global pm = char(177)
		set more off
		gl date = c(current_date)
		graph set window fontface "cmr10"
		
		
* set cd as /Replication_files_HanspalWeberWohlfart2020/

*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~						
** FIGURE A15
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	

use data/processed/data_1, clear 
keep if control_pure ==1
gen wealthloss = (del_finwealth_perc_tr02<0)
gen incomeloss = (del_hhnetinc_perc_tr02<0)
replace wealthloss = . if wealthloss==0
replace incomeloss = . if incomeloss==0
replace recovery_duration = recovery_duration*wealthloss
replace recov_hhwealth_duration   = recov_hhwealth_duration*wealthloss
replace recov_owninc_duration = recov_owninc_duration*incomeloss
replace never_ownwealth   = never_ownwealth*wealthloss
replace never_owninc = never_owninc*incomeloss

	foreach x in  never_ownwealth  never_owninc{	
		replace `x' = `x'*100
	}	
	
* Expected duration of recovery
	*  by netwealth
	graph bar (mean)   recovery_duration recov_hhwealth_duration  recov_owninc_duration  , ///
			over(netwealth_Jan20_grp, relabel(1 1 2 2 3 3 4 4 5 5)) b1title(Net wealth quintile, size(medsmall)) ///
			  bargap(0) exclude0 /// 
			ytitle("Expected duration of recovery (years)", size(medsmall)) ///
			graphregion(color(white)) bgcolor(white) ///
			ylabel(0(.5)2.5, nogrid)   legend(size(small) pos(6) ring(1) cols(6) ///
			label(1 "Stock market") label(2 "Houshold wealth") ///
			label(3 "Personal income")) saving(Figures/temp1.gph, replace)		
			
	* never recover by netwealth
	graph bar (mean)   never_ownwealth  never_owninc , ///
			over(netwealth_Jan20_grp, relabel(1 1 2 2 3 3 4 4 5 5))  b1title(Net wealth quintile, size(medsmall)) ///
			  bargap(0) exclude0  bar(1, fcolor(gs10)) bar(2, fcolor(gs12))  /// 
			ytitle("Expected to never recover (%)", size(medsmall)) ///
			 graphregion(color(white)) bgcolor(white) ///
			ylabel(0(10)30, nogrid)   legend(size(small) pos(6) ring(1) cols(6) ///
			label(1 "Houshold wealth") ///
			label(2 "Personal income")) saving(Figures/temp2.gph, replace)		
					
	* recovery_duration by age
	graph bar (mean)  recovery_duration recov_hhwealth_duration  recov_owninc_duration , ///
			over(agecat, relabel(1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+") label(labsize(small))) b1title(Age group) ///
			  bargap(0) exclude0  /// 
			ytitle("x", size(medsmall)) ///
			 graphregion(color(white)) bgcolor(white) ///
			ylabel(0(.5)2.5, nogrid)   legend(size(small) pos(6) ring(1) cols(6) ///
			label(1 "Stock market") label(2 "Houshold wealth") ///
			label(3 "Personal income")) saving(Figures/temp3.gph, replace)		
			
	* never recover  by age
	graph bar (mean)  never_ownwealth  never_owninc  , ///
			over(agecat, relabel(1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65+") label(labsize(small))) b1title(Age group) ///
			  bargap(0) exclude0  bar(1, fcolor(gs10)) bar(2, fcolor(gs12))  /// 
			ytitle("", size(medsmall)) ///
			 graphregion(color(white)) bgcolor(white) ///
			ylabel(0(10)30, nogrid)   legend(size(small) pos(6) ring(1) cols(6) ///
			label(1 "Houshold wealth") ///
			label(2 "Personal income")) saving(Figures/temp4.gph, replace)		
			
	* recovery_duration  by netincome
	graph bar (mean)  recovery_duration recov_hhwealth_duration  recov_owninc_duration , ///
			over(hhnetinc_2019_grp)  b1title(Net income quintile, size(medsmall)) ///
			  bargap(0) exclude0 /// 
				ytitle("x", size(medsmall)) ///
			 graphregion(color(white)) bgcolor(white) ///
			ylabel(0(.5)2.5, nogrid)   legend(size(small) pos(6) ring(1) cols(6) ///
			label(1 "Stock market") label(2 "Houshold wealth") ///
			label(3 "Personal income")) saving(Figures/temp5.gph, replace)		
			
	* never recover  by netincome
	graph bar (mean)  never_ownwealth  never_owninc  , ///
			over(hhnetinc_2019_grp)  b1title(Net income quintile, size(medsmall)) ///
			  bargap(0) exclude0  bar(1, fcolor(gs10)) bar(2, fcolor(gs12))  /// 
			ytitle("Expected to never recover (%)", size(medsmall)) ///
			 graphregion(color(white)) bgcolor(white) ///
			ylabel(0(10)30, nogrid)   legend(size(small) pos(6) ring(1) cols(6) ///
			label(1 "Houshold wealth") ///
			label(2 "Personal income")) saving(Figures/temp6.gph, replace)		
			
			
	grc1leg2 		Figures/temp1.gph ///
					Figures/temp5.gph ///
					Figures/temp3.gph,  ytol1title  cols(1) ysize(3) xsize(2) ///
					ring(1) pos(6) hole(4)legendfrom(Figures/temp1.gph) lsize(vsmall) saving(Figures/tempA.gph, replace)		 
					
	grc1leg2 		Figures/temp2.gph ///
					Figures/temp6.gph ///
					Figures/temp4.gph,  ytol1title  cols(1) ysize(3) xsize(2) ///
					ring(1) pos(6) hole(4)legendfrom(Figures/temp2.gph) lsize(vsmall) saving(Figures/tempB.gph, replace)		 
		
	graph combine 		///
				Figures/tempA.gph ///
				Figures/tempB.gph , cols(2) ysize(3) xsize(4) 
	
	graph export Figures/FigureA15.pdf, as(pdf)  fontface("cmr10") replace		
	graph export Figures/FigureA15.png, width(1600) replace		
	

	
forvalues x = 1/6 {
		capture erase Figures/temp`x'.gph
}		
		capture erase Figures/tempA.gph
		capture erase Figures/tempB.gph	
